<template>
	<view :data-theme="theme">
		<view class='hotList' v-if="productList.length > 2">
			<view class='title acea-row row-between-wrapper'>
				<view class='text line1'>
					<text class="iconfont icon-jingpintuijian1"></text> 
					<text class='label'>商品排行榜</text>
				</view>
				<view class='more' hover-class="none" @click="more()">更多
					<text class="iconfont icon-jiantou"></text>
				</view>
			</view>
			<view class='list'>
				<block>
					<view class="item acea-row row-middle" :class="{'lei' : index < 2}" v-for="(item,index) in productList.slice(0,3)" :key="index" @click="toDetail(item.id)">
						<view class="img_box">
							<image class="pictrue" :src="item.image"></image>
							<view  class="rank_bdg top_1" v-if="index == 0">热榜TOP1</view>
							<view  class="rank_bdg top_2" v-else-if="index == 1">热榜TOP2</view>
							<view  class="rank_bdg top_3" v-else-if="index == 2">热榜TOP3</view>
						</view>
						<view class="ml_11 flex-column justify-between flex-1">
							<view class="goods_name">{{item.storeName}}</view>
							<view class="price flex justify-between">
								<view>
									<text class="price_bdg">￥</text>{{item.price}}
									<text class="sales">销量 {{item.sales}}件</text>
								</view>
								<view class="cart_icon">
									<text class="iconfont icon-gouwuche7"></text>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
	let app = getApp()
	import {mapState} from 'vuex';
	import animationType from '@/utils/animationType.js'
	import {productRank} from '@/api/api.js'
	export default {
		name: 'goodList',
		props: {
			dataConfig: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				theme:app.globalData.theme,
				productList: [],
			}
		},
		created() {
			this.getProductRank();
		},
		methods:{
			toDetail(id){
				uni.navigateTo({
					animationType: animationType.type,
					animationDuration: animationType.duration,
					url:'/pages/goods_details/index?id=' + id
				})
			},
			getProductRank(){
				productRank().then(res=>{
					this.productList = res.data;
				})
			},
			more(){
				let typeInfo = {
					type:'rank',
					name:'商品排行'
				}
				uni.navigateTo({
					animationType: animationType.type,
					animationDuration: animationType.duration,
					url:'/pages/activity/promotionList/index?type=' + JSON.stringify(typeInfo)
				})
			}
		}
	}
</script>

<style lang="scss">
	.hotList {
		background-color: #fff;
		margin: 30rpx 0 0;
		border-radius: 12rpx;
	}

	.hotList .hot-bg {
		width: 100%;
		height: 120rpx;
		box-sizing: border-box;
		font-size: 24rpx;
		color: #282828;
		margin-top: 15rpx;

	}

	.hotList .title {
		padding: 24rpx 20rpx 0 20rpx;
	}

	.hotList .title .text {
		width: 500rpx;
		color: #999999;
		font-size: 12px;
		display: flex;
		align-items: flex-end;
	}
	
	.icon-jingpintuijian1{
		@include main_color(theme);
		font-size: 42rpx;
	}
	.hotList .title .text .label {
		font-size: 36rpx;
		font-weight: bold;
		color: #282828;
		margin-right: 12rpx;
		margin-left:12rpx;
	}

	.hotList .title .more {
		font-size: 26rpx;
		color: #999999;
		;
	}

	.hotList .title .more .iconfont {
		font-size: 25rpx;
		margin-left: 10rpx;
	}

	.hotList .list {
		width: 690rpx;
		border-radius: 20rpx;
		background-color: #fff;
		margin: 0rpx auto 0 auto;
		padding: 0 20rpx 30rpx;
		box-sizing: border-box;
	}
	.hotList .list .item {
		background: #fff;
		margin-top: 26rpx;
	}
	.lei{
		padding-bottom: 26rpx;
		position: relative;
		&::after{
			content: '';
			position: absolute;
			bottom: 0;
			right: 0;
			width: 460rpx;
			height: 2rpx;
			background-color: #eee;
		}
	}
	.img_box{
		width: 180rpx;
		height: 180rpx;
		background: #F3F3F3;
		position: relative;
		.pictrue{
			width:100%;
			height:100%;
			border-radius: 10rpx;
		}
		.rank_bdg{
			width: 100%;
			height: 46rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			margin: auto;
			text-align: center;
			color: #fff;
			font-size: 24rpx;
			line-height: 46rpx;
			background-size: 100%;
			background-repeat: no-repeat;
		}
	}
	.ml_11{
		margin-left: 22rpx;
	}
	.flex-1{
		flex: 1;
	}
	.goods_name{
		width: 420rpx;
		height: 80rpx;
		font-size: 30rpx;
		font-weight: 400;
		color: #333333;
		line-height: 40rpx;
		overflow: hidden;
		text-overflow:ellipsis;
		white-space: wrap;
	}
	.price{
		margin-top: 60rpx;
		font-size: 34rpx;
		font-weight: 600;
		@include price_color(theme);
		.price_bdg{
			font-size: 26rpx;
		}
		.sales{
			font-size: 24rpx;
			color: #999999;
			font-weight: 400;
			padding-left: 12rpx;
		}
		.cart_icon{
			width: 48rpx;
			height: 48rpx;
			border-radius: 50%;
			@include main_bg_color(theme);
			// text-align: center;
			// line-height: 40rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			.iconfont{
				font-size: 28rpx;
				font-weight: 400;
				color: #fff;
			}
		}
	}
	.top_1{
		background-image: url('');
	}
	.top_2{
		background-image: url('');
	}
	.top_3{
		background-image: url('');
	}
</style>